package com.lu.tool.thread

import android.os.Handler
import android.os.Looper

/**
 *author: luqihua
 *date:2021/11/22
 *description:
 **/
object HandlerTools {
    private val mainHandler = Handler(Looper.getMainLooper())

    @JvmStatic
    fun postMain(task: Runnable) {
        mainHandler.post(task)
    }


    @JvmStatic
    fun postMainDelay(delayMillis: Long, task: Runnable) {
        mainHandler.postDelayed(task, delayMillis)
    }

    @JvmStatic
    fun updateMainDelay(delayMillis: Long, task: Runnable) {
        mainHandler.removeCallbacks(task)
        mainHandler.postDelayed(task, delayMillis)
    }

    @JvmStatic
    fun removeMainTask(task: Runnable) {
        mainHandler.removeCallbacks(task)
    }

}